//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.ControlPanel.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using FormLabel = CommunityServer.ControlPanel.Controls.FormLabel;
using HelpIcon = CommunityServer.ControlPanel.Controls.HelpIcon;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;

namespace CommunityServer.ControlPanel.Blogs
{
	/// <summary>
	/// Summary description for PostEditorPage.
	/// </summary>
	public class AboutOptionsPage : BaseBlogPage
	{

		#region Child Controls

        protected TextBox AboutTitle;
        protected Editor AboutDescription;
		protected ConfigOKStatusMessage Status;
		protected ResourceLinkButton SaveButton;
		protected ControlPanelSelectedNavigation SelectedNavigation1;
		protected ResourceControl Resourcecontrol1;
		protected MPContent DescriptionRegion;
		protected ResourceControl Resourcecontrol2;
		protected HelpIcon Helpicon1;
		protected FormLabel FormLabel1;
		protected HelpIcon Helpicon2;
		protected FormLabel FormLabel2;
		protected MPContent TaskRegion;
		protected MPContainer MPContainer;
		protected YesNoRadioButtonList ynEnableAbout;
	
		#endregion

		private void Page_Load(object sender, EventArgs e)
		{
            SaveButton.Text = ResourceManager.GetString("Save");
			if(!IsPostBack)
			{
				ynEnableAbout.SelectedValue = this.CurrentWeblog.EnableAbout;
				AboutTitle.Text = this.CurrentWeblog.AboutTitle;
                AboutDescription.Text = this.CurrentWeblog.AboutDescription;
			}
		}

		override protected void OnInit(EventArgs e)
		{
			this.Load += new EventHandler(this.Page_Load);
            this.SaveButton.Click += new EventHandler(this.SaveButton_Click);

            base.OnInit(e);
            this.RefreshCurrentWeblog();
        }

        private void SaveButton_Click(object sender, EventArgs e)
        {
            if(Page.IsValid)
            {
				CurrentWeblog.AboutTitle = AboutTitle.Text;
                CurrentWeblog.AboutDescription = AboutDescription.Text;
				CurrentWeblog.EnableAbout = ynEnableAbout.SelectedValue;

            	Weblogs.Update(CurrentWeblog);
				
				Status.Success = true;
				Status.Visible = true;
            }
        }
	}
}
